package com.haochu.qipaipuzi.ui;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.haochu.qipaipuzi.R;
import com.haochu.qipaipuzi.common.task.GenericTask;
import com.haochu.qipaipuzi.common.task.base.TaskParams;
import com.haochu.qipaipuzi.common.task.base.TaskResult;
import com.haochu.qipaipuzi.network.cmd.Client;

public class IndexActivity extends Activity implements View.OnClickListener {

    Button button;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_index);

        button = findViewById(R.id.button);
        button.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {

        switch (v.getId()) {
            case R.id.button:
                CheckJoinTask checkJoinTask = new CheckJoinTask();
                checkJoinTask.execute(new TaskParams());
                break;
            default:
                break;
        }


    }

    /**
     * 加入房间前校验线程任务
     */
    private class CheckJoinTask extends GenericTask {

        protected TaskResult _doInBackground(TaskParams... params) {
            try {
//                Client client = new Client("127.0.0.1", 11111);
                Client client = new Client("192.168.0.100", 11111);
                client.sendMsg("hahaha");

            } catch (Exception e) {
            }
            return TaskResult.FAILED;
        }
    }
}


